package com.ruoyi.web.controller.biz;

import java.util.Arrays;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.biz.domain.BizPwdType;
import com.ruoyi.biz.service.BizPwdTypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 密码类型Controller
 * 
 * @author tianl
 * @date 2025-02-08
 */
@RestController
@RequestMapping("/biz/bizPwdType")
public class BizPwdTypeController extends BaseController {
    @Autowired
    private BizPwdTypeService bizPwdTypeService;

    /**
     * 密码类型全部列表
     */
    @GetMapping(value = "/listAll")
    public AjaxResult listAll(BizPwdType bizPwdType) {
        return success(bizPwdTypeService.list(bizPwdType));
    }

    /**
     * 查询密码类型列表
     */

    @GetMapping("/list")
    public AjaxResult list(BizPwdType bizPwdType) {
        List<BizPwdType> list = bizPwdTypeService.list(bizPwdType);
        return success(list);
    }

    /**
     * 导出密码类型列表
     */

    @Log(title = "密码类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizPwdType bizPwdType) {
        List<BizPwdType> list = bizPwdTypeService.list(bizPwdType);
        ExcelUtil<BizPwdType> util = new ExcelUtil<>(BizPwdType.class);
        util.exportExcel(response, list, "密码类型数据");
    }

    /**
     * 获取密码类型详细信息
     */

    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(bizPwdTypeService.selectById(id));
    }

    /**
     * 新增密码类型
     */

    @Log(title = "密码类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizPwdType bizPwdType) {
        bizPwdTypeService.beforeSave(bizPwdType);
        return AjaxResult.success();
    }

    /**
     * 修改密码类型
     */

    @Log(title = "密码类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizPwdType bizPwdType) {
        bizPwdTypeService.beforeSave(bizPwdType);
        return AjaxResult.success();
    }

    /**
     * 删除密码类型
     */

    @Log(title = "密码类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(bizPwdTypeService.deleteByIds(Arrays.asList(ids)));
    }
}
